package com.bestcem.xm.cjm.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.bestcem.xm.cjm.enums.CjmContentTypeEnum.CONTENT_TYPE_TEXT;
import static com.bestcem.xm.cjm.enums.CjmRowsHiddenEnum.COLUMNS_HIDDEN_FALSE;
import static com.bestcem.xm.cjm.enums.CjmRowsTTypeEnum.*;

/**
 * 常量类
 */
public interface CjmConstant {

    static Map<String, Object> customizeData() {
        Map<String, Object> t = new HashMap<>();
        t.put("ctype", CONTENT_TYPE_TEXT.getValue());
        t.put("name", "");
        t.put("content", "");
        t.put("icon", "");
        t.put("narrow_icon", "");
        t.put("icon_name", "");
        t.put("layout", layout());
        return t;
    }

    static Object layout() {
        Map<String, Object> layy = new HashMap<>();
        layy.put("verticleLayout", 2);
        layy.put("horizontalLayout", 2);
        return layy;
    }

    static Object initData() {
        Map<String, Object> data = new HashMap<>();
        data.put("index_num", 1);
        data.put("order", 1);
        data.put("index", indexSignature());
        return data;
    }

    static Object indexSignature() {
        ArrayList<Map<String, Object>> dataList = new ArrayList<>();
        HashMap<String, Object> map = new HashMap<>();
        map.put("chart_signature", "");
        map.put("dashboard_signature", "");
        dataList.add(map);
        return dataList;
    }

    Map<Integer, String> NUMBER_MAP = new HashMap<Integer, String>() {{
        put(1, "一");
        put(2, "二");
        put(3, "三");
        put(4, "四");
        put(5, "五");
        put(6, "六");
        put(7, "七");
        put(8, "八");
        put(9, "九");
        put(10, "十");
        put(11, "十一");
        put(12, "十二");
        put(13, "十三");
        put(14, "十四");
        put(15, "十五");
        put(16, "十六");
        put(17, "十七");
        put(18, "十八");
        put(19, "十九");
        put(20, "二十");

    }};

    Map<String, Object> CONTACTPOINT_ICON_DATA = new HashMap<String, Object>() {{
        put("目标", "%s/cjm/cjm_icon/target.svg");
        put("对话", "%s/cjm/cjm_icon/dialogue.svg");
        put("文档", "%s/cjm/cjm_icon/documentation.svg");
        put("好评", "%s/cjm/cjm_icon/praise.svg");
        put("保障", "%s/cjm/cjm_icon/assure.svg");
        put("数据", "%s/cjm/cjm_icon/data.svg");
    }};

    Map<String, Object> CONTACTPOINT_DATA = new HashMap<String, Object>() {{
        put("contactpoint_num", 1);
        put("order", 1);
        put("contactpoint", new ArrayList<Map<String, Object>>() {{
            add(new HashMap<String, Object>() {{
                put("name", "触点1");
                put("icon", "");
                put("icon_name", "");
            }});
        }});
    }};

    List<Map<String, Object>> ROWS_DATA = new ArrayList<Map<String, Object>>() {{
        add(new HashMap<String, Object>() {{
            put("name", "阶段");
            put("ttype", ROWS_TTYPE_STAGE.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "客户目标");
            put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "触点");
            put("ttype", ROWS_TTYPE_CONTACTPOINT.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "触达方式");
            put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "客户想法");
            put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "指标");
            put("ttype", ROWS_TTYPE_INDEX.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "总结");
            put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
    }};

    List<Map<String, Object>> COLUMNS_DATA = new ArrayList<Map<String, Object>>() {{
        add(new HashMap<String, Object>() {{
            put("name", "阶段一");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "阶段二");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "阶段三");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "阶段四");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "阶段五");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
        add(new HashMap<String, Object>() {{
            put("name", "阶段六");
            put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
        }});
    }};

    List<Map<String, Object>> DATA_INIT = new ArrayList<Map<String, Object>>() {
        {
            add(new HashMap<String, Object>() {
                {
                    put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
                    put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                    put("data", initCustomizeData("客户目标"));
                }
            });
            add(new HashMap<String, Object>() {{
                put("ttype", ROWS_TTYPE_CONTACTPOINT.getValue());
                put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                put("data", initContactpointData());
            }});
            add(new HashMap<String, Object>() {{
                put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
                put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                put("data", initCustomizeData("触达方式"));
            }});
            add(new HashMap<String, Object>() {{
                put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
                put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                put("data", initCustomizeData("客户想法"));
            }});
            add(new HashMap<String, Object>() {{
                put("ttype", ROWS_TTYPE_INDEX.getValue());
                put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                put("data", initRowsData());
            }});
            add(new HashMap<String, Object>() {{
                put("ttype", ROWS_TTYPE_CUSTOMIZE.getValue());
                put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                put("data", initCustomizeData("总结"));
            }});
        }


        private List<Map<String, Object>> initCustomizeData(String str) {
            List<Map<String, Object>> res = new ArrayList<>();
            for (int i = 0; i < COLUMNS_DATA.size(); i++) {
                Map<String, Object> data = customizeData();
                data.put("content", str + NUMBER_MAP.get(i + 1));
                res.add(new HashMap<String, Object>() {{
                    put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                    put("data", data);
                }});
            }
            return res;
        }

        private List<Map<String, Object>> initRowsData() {
            List<Map<String, Object>> res = new ArrayList<>();
            for (int i = 0; i < COLUMNS_DATA.size(); i++) {
                res.add(new HashMap<String, Object>() {{
                    put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                    put("data", initData());
                }});
            }
            return res;
        }

        private List<Map<String, Object>> initContactpointData() {
            List<Map<String, Object>> res = new ArrayList<>();
            CONTACTPOINT_ICON_DATA.forEach((name, path) -> {
                Map<String, Object> data = new HashMap<>(CONTACTPOINT_DATA);
                data.put("contactpoint", new ArrayList<Map<String, Object>>() {{
                    add(new HashMap<String, Object>() {{
                        put("name", "触点1");
                        put("icon", path);
                        put("icon_name", name);
                    }});
                }});
                res.add(new HashMap<String, Object>() {{
                    put("hidden", COLUMNS_HIDDEN_FALSE.getValue());
                    put("data", data);
                }});
            });
            return res;
        }
    };
}